package com.havey.ye;

/**
 * @author huaiwei.com.havey.ye
 * @description: 收费容器
 * @date 2021/2/9 17:32
 */
public class CashContext {

    private CashSuper cashSuper;

    public CashContext(String type) {
        switch (type){
            case "正常收费":
                cashSuper=new CashNormal();
                break;
            case "满300减100":
                cashSuper=new CashReturn(300,100);
                break;
            case "打八折":
                cashSuper=new CashRebate(0.8);
                break;
        }
    }

    public double getResult(double money){
        return cashSuper.acceptCash(money);
    }
}
